from ronglian_sms_sdk import SmsSDK
from utils.main import app
import redis,random

accId = '8aaf070882ede8b30183546f86be1255'
accToken = 'b348b78dc9654ff68238a6c2c87eea74'
appId = '8aaf070882ede8b30183546f878d125c'

@app.task

def send_message(phone):
    sdk=SmsSDK(accId,appId,accToken)
    tid='1'
    data=random.randint(100000,999999)
    r=redis.Redis(host="127.0.0.1",port=6379,db=1)
    r.set(f'sms_code_{phone}',data,ex=300)
    datas=(data,5)
    resp=sdk.sendMessage(tid,phone,datas)
    print(resp)
    return resp
